﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Deployment.Application;

namespace WinApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //判断是不是ClickOnce应用
            if (!ApplicationDeployment.IsNetworkDeployed)
            {
                return;
            }
            //得到URL的查询条件(URL?后面的值,包括?)
            string queryString = ApplicationDeployment.CurrentDeployment.ActivationUri.Query;
            if (queryString.Length < 2)
            {
                return;
            }
            queryString = queryString.Substring(1);
            string[] QueryPar = queryString.Split('&');
            string res = string.Empty;
            foreach (string str in QueryPar)
            {
                res += "\r\n" + str;
            }
            res = res.Substring(2);
            label1.Text = res;
        }

        /// <summary>
        /// 得到URL的字典对象
        /// </summary>
        /// <returns>Dictionary<string, string></returns>
        private Dictionary<string, string> GetDic()
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            //得到全部的URL
            string url = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0];
            string queryString = (new Uri(url)).Query;
            queryString = queryString.Substring(1);
            string[] QueryPar = queryString.Split('&');
            foreach (string str in QueryPar)
            {
                string[] OnePar = str.Split('=');
                dic.Add(OnePar[0], OnePar[1]);
            }
            return dic;
        }
    }
}
